<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<link rel="stylesheet" href="css/form.css" />
</head>

<body>
	<div id="header-wrap" data-mn=0>
		<a href="###" data-link="back" data-type="ico" class="left ico-m ico-left"></a>
		<h2>赎回富贵天天</h2>
		<!-- <a href="###" data-link="tariff" class="right btn b-small b-red">说明</a> -->
	</div>
	<div class="" id="">
		<div class="tips">
			<div class="t-info">可赎回份额 <b id="keep"></b>份</div>
			<div class="t-error"></div>
		</div>
		<form>
		<ul class="form-list c-right" id="">
			<li class="ico-m ico-pl ico-red ico-rmb" data-type="ico">
				<div class="fl-cont form-input">
					<input type="number" id="sh" placeholder="请输赎回份额" value="" />
				</div>
			</li>
			<li class="ico-m ico-pl ico-change" data-type="ico">
				<div class="fl-cont form-input">
					手续费：0元
				</div>
			</li>
			<li class="ico-m ico-pl ico-ok" data-type="ico">
				<div class="fl-cont form-input">
					实际到账：<span id="dz"></span>
				</div>
			</li>
		</ul>
		<div class="fixed-btn">
			<a href="###" data-link="redeem-t-1" class="btn b-red"><span id="check">赎回</span></a>
		</div>
		</form>
		<div class="feed-info">
			<h2>如有疑问，请咨询...</h2>
			客服电话：400-105-8851<br />
			微信客服：wuyifugui(公众号)
		</div>
	</div>
	<script>
	$(function(){
		var keep = Number($.cookie("keep_n"));
		$("#keep").text(keep)
		if(keep < 1 ){
			alert("可赎回份额不足，请先购买富贵天天理财产品")
			load_page("buy")
		}else{
			$("#sh").on("keyup",function(){
				var val = parseInt($(this).val(),10)
				$(this).val(val);
				val = $(this).val();
				if(isNaN(val[0])){
					$("#dz").text("0元")
				}else{
					if(val > keep){
						$(".t-error").text("赎回份额超限，本次可赎回 "+keep+" 份").fadeIn(100)
						$(".t-info").hide();
						reset_tip()
						$("#dz").text(keep+"元")
						$(this).val(keep);
						return false
					}else{
						$("#dz").text(val+"元")
					}
				}
			})
			$("#check").on("click",function(){
				var sh = $("#sh").val();
				var sh_return = $("#sh").check({type:8});
				if(sh == ''){
					$(".t-error").text("赎回份额不能为空").fadeIn(100)
					$(".t-info").hide();
					reset_tip()
					return false
				}else if (sh_return == 0){
					$(".t-error").text("请输入有效赎回份额").fadeIn(100)
					$(".t-info").hide();
					reset_tip()
					return false
				}else{
					if(sh > keep){
						$(".t-error").text("赎回超额，最多可赎回 "+keep+" 份").fadeIn(100)
						$(".t-info").hide();
						reset_tip()
						return false
					}else{
						keep -= sh
					}
					$.cookie("sh_temp",sh);
					$.cookie("keep_temp",keep);
				}
			})
		}
	})
	</script>	
</body>

</html>
